package com.zzyl.elder.service.impl;

import java.util.List;
import com.zzyl.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.elder.mapper.RoomMapper;
import com.zzyl.elder.domain.Room;
import com.zzyl.elder.service.IRoomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
/**
 * 房间Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements IRoomService
{
    @Autowired
    private RoomMapper roomMapper;

    /**
     * 查询房间
     * 
     * @param id 房间主键
     * @return 房间
     */
    @Override
    public Room selectRoomById(Long id)
    {
        return super.getById(id);
    }

    /**
     * 查询房间列表
     * 
     * @param room 房间
     * @return 房间
     */
    @Override
    public List<Room> selectRoomList(Room room)
    {
        return roomMapper.selectRoomList(room);
    }

    /**
     * 新增房间
     * 
     * @param room 房间
     * @return 结果
     */
    @Override
    public int insertRoom(Room room)
    {
        room.setCreateTime(DateUtils.getNowDate());
        return super.save(room) ? 1 : 0;
    }

    /**
     * 修改房间
     * 
     * @param room 房间
     * @return 结果
     */
    @Override
    public int updateRoom(Room room)
    {
        room.setUpdateTime(DateUtils.getNowDate());
        return super.updateById(room) ? 1 : 0;
    }

    /**
     * 批量删除房间
     * 
     * @param ids 需要删除的房间主键
     * @return 结果
     */
    @Override
    public int deleteRoomByIds(Long[] ids)
    {
        return super.removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除房间信息
     * 
     * @param id 房间主键
     * @return 结果
     */
    @Override
    public int deleteRoomById(Long id)
    {
        return super.removeById(id) ? 1 : 0;
    }
}
